<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i">
<input type="button" value="平方" onclick="f()">
<div>结果：<span></span></div>
<script>
    function f() {
        let i = document.querySelector("#i")
        let s = document.querySelector("span")
        if (isNaN(i.value)) {
            s.innerText = "输入错误！"
            return;
        }
        s.innerText = parseFloat(i.value)+parseFloat(i.value)
        //s.innerText =  i.value * i.value;
    }
</script>
</body>
</html>